package generic_test;

/**
 * @author yuisama
 * @date 2022/05/08 16:30
 **/
public class Point {
    private Object x;
    private Object y;

    public void setX(Object x) {
        this.x = x;
    }

    public void setY(Object y) {
        this.y = y;
    }

    public Object getX() {
        return x;
    }

    public Object getY() {
        return y;
    }

    public static void main(String[] args) {
//        Point point1 = new Point();
//        point1.setX(10);
//        point1.setY(20);
//        int x = (int) point1.getX();
//        int y = (int) point1.getY();
//        System.out.println("x = " + x + ", y = " + y);
//        Point point1 = new Point();
//        // 要求此时x和y必须是相同类型的，设置是由用户设置的
//        point1.setX("东经20度");
//        point1.setY("北纬30度");
//        String x = (String) point1.getX();
//        String y = (String) point1.getY();
//        System.out.println("x = " + x + ", y = " + y);
        Point point = new Point();
        point.setX(10);
        point.setY("北纬30度");
        String x = (String) point.getX();
        String y = (String) point.getY();
        System.out.println("x = " + x + ", y = " + y);
    }
}